package data;

import java.util.HashMap;

import org.w3c.dom.NodeList;
import java.util.Date;

public abstract class DOMReader {
	public Record read(HashMap<String, NodeList> context) throws Exception {
		Record r = new Record();
		
		r.setName(getName(context.get(Record.NAME)));
		r.setSymbol(getSymbol(context.get(Record.SYMBOL)));
		r.setMinRate(getMinRate(context.get(Record.MIN)));
		r.setMaxRate(getMaxRate(context.get(Record.MAX)));
		r.setCurrentRate(getCurrRate(context.get(Record.CURR)));
		r.setOpeningRate(getOpeningRate(context.get(Record.OPEN)));
		r.setClosingRate(getClosingRate(context.get(Record.CLOSE)));
		r.setTimeStamp(getDate(context.get(Record.DATE)));

		return r;
	}
	
	protected abstract String getName(NodeList nl) throws Exception;
	
	protected abstract String getSymbol(NodeList nl) throws Exception;

	protected abstract float getMinRate(NodeList nl) throws Exception;

	protected abstract float getMaxRate(NodeList nl) throws Exception;

	protected abstract float getOpeningRate(NodeList nl) throws Exception;

	protected abstract float getClosingRate(NodeList nl) throws Exception;

	protected abstract float getCurrRate(NodeList nl) throws Exception;

	protected abstract Date getDate(NodeList nl) throws Exception;
}
